<?php
  require_once('db_connection.php');
  if(isset($_POST['register'])) {
    print_r($_POST);

    $_POST = array_map('trim',$_POST);
    $_POST = array_map('mysql_real_escape_string',$_POST);
    //$_POST = array_map('addslashes',$_POST);

    $name = $_POST['name'];
    $email = $_POST['email'];
    $password = $_POST['password'];
    $added_date = date('Y-m-d H:i:s');

    echo $query = "INSERT INTO `users`
    (`name`,`email`,`password`,`added_date`,`status`)
    VALUES
    ('$name','$email','$password','$added_date','0')";
//echo $query;
    mysql_query($query) or die(mysql_error());

    $rows_affected = mysql_affected_rows();
    $id = mysql_insert_id();

    echo "<h4>OK</h4>";
    echo "<h4>$rows_affected record INSERTED on ID $id</h4>";
  } else {
    echo "<h4>:(</h4>";
  }
?>

<form action="" method="post">
  <table  border="1" cellpadding="0" cellspacing="0" width="80%" align="center">
    <thead>
      <tr>
        <th colspan="2">Please fill the details below:-</th>
      </tr>
    </thead>
    <tbody>

      <tr>
        <td align="right">Name :</td>
        <td><input type="text" name="name" required /></td>
      </tr>

      <tr>
        <td align="right">Email :</td>
        <td><input type="email" name="email" required /></td>
      </tr>

      <tr>
        <td align="right">Password :</td>
        <td><input type="password" name="password" required /></td>
      </tr>

      <tr>
        <td align="right">&nbsp;</td>
        <td><input type="submit" name="register" value="I am done!! " /></td>
      </tr>

    </tbody>
  </table>

</form>
